
package vip.xiaonuo.biz.modular.lancerGoodskill.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import vip.xiaonuo.biz.modular.lancerGoodskill.entity.BizGoodsKill;
import vip.xiaonuo.biz.modular.lancerGoodskill.param.BizGoodsKillAddParam;
import vip.xiaonuo.biz.modular.lancerGoodskill.param.BizGoodsKillEditParam;
import vip.xiaonuo.biz.modular.lancerGoodskill.param.BizGoodsKillIdParam;
import vip.xiaonuo.biz.modular.lancerGoodskill.param.BizGoodsKillPageParam;
import vip.xiaonuo.biz.modular.lancerGoodskill.service.BizGoodsKillService;
import vip.xiaonuo.biz.modular.pojo.vo.ClientGoodsKillVO;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.common.pojo.CommonValidList;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;

/**
 * 秒杀控制器
 *
 * @author Lancer
 * @date  2024/03/03 17:01
 */
@Api(tags = "秒杀(C端)")
@ApiSupport(author = "LANCER_TEAM", order = 1)
@RestController
@Validated
public class ClientGoodsKillController {

    @Resource
    private BizGoodsKillService bizGoodsKillService;

    @ApiOperationSupport(order = 1)
    @ApiOperation("C端获取秒杀分页")
    @GetMapping("/biz/client/goodskill/page")
    public CommonResult<Page<ClientGoodsKillVO>> page(BizGoodsKillPageParam bizGoodsKillPageParam) {
        return CommonResult.data(bizGoodsKillService.pageClient(bizGoodsKillPageParam));
    }
    @ApiOperationSupport(order = 1)
    @ApiOperation("C端获取正在进行的秒杀")
    @GetMapping("/biz/client/goodskill/doingKill")
    public CommonResult<Page<ClientGoodsKillVO>> doingKill() {
        return CommonResult.data(bizGoodsKillService.doingKill());
    }
    @ApiOperationSupport(order = 3)
    @ApiOperation("商品秒杀（生成订单）")
    @GetMapping("/biz/client/goodskill/killGoods/{id}")
    public CommonResult<String> buyGoodsByAliPay(@PathVariable String id,
                                                 HttpServletResponse httpResponse) {
        bizGoodsKillService.killGoods(id,httpResponse);
        return CommonResult.ok();
    }
}
